package com.example.a828502.arraysortrest;

import java.util.Comparator;

/**
 * Created by 828502 on 2016/5/5.
 */
public class SortComparator implements Comparator {
    @Override
    public int compare(Object lhs, Object rhs) {
        User a = (User) lhs;
        User b = (User) rhs;
        int compareName = a.getName().compareTo(b.getName());
        if (compareName == 0) {
            return (a.getName() == a.getName() ? 0 : (b.getAge() > b.getAge() ? 1 : -1));
        }
        return compareName;
    }


}
